package org.liulinlin.sejw.db;

import java.sql.*;


public class BoxConstraints {
	private int id;
	private int gp20;
	private int gp40;
	private int hq40;
	
	public BoxConstraints() {
		
	}
	public BoxConstraints(int id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from BoxConstraints where BC_ID ='" + id + "'");
		
			rs.next();
			this.id = id;
			gp20 = rs.getInt("BC_20GP");
			gp40 = rs.getInt("BC_40GP");
			hq40 = rs.getInt("BC_40HQ");
			
			stmt.close();
			rs.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		
		connMgr.release();
	}
	/*
	public BoxConstraints() {
		connMgr = DBConnectionManager.getInstance();
	}
	public BoxConstraints(int id) {
		connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from BoxConstraints where BC_ID ='" + id + "'");
		
			rs.next();
			this.id = id;
			gp20 = rs.getInt("BC_20GP");
			gp40 = rs.getInt("BC_40GP");
			hq40 = rs.getInt("BC_40HQ");
			
			stmt.close();
			rs.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
	}
	*/
	
	public void setId(int id) {
		this.id = id;
	}
	public void setGP20(int gp20) {
		this.gp20 = gp20;
	}
	public void setGP40(int gp40) {
		this.gp40 = gp40;
	}
	public void setHQ40(int hq40) {
		this.hq40 = hq40;
	}
	
	public int getId() {
		return id;
	}
	public int getGP20() {
		return gp20;
	}
	public int getGP40() {
		return gp40;
	}
	public int getHQ40() {
		return hq40;
	}
}
